home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_07 / wilde / conv.syn < prev    next >
Text File  |  1993-11-27  |  2KB  |  65 lines

  1. {
  2. /*
  3.  File:   CONV.SYN - AnaGram syntax file for
  4.                     conversion program;
  5.          Version 1
  6. */
  7. #include "string.h"
  8. #include "convutil.h"
  9. }
  10. [
  11.   parser file name = "conv.cpp"
  12. ]
  13.  
  14. grammar
  15.  -> record?..., eof
  16.  
  17. (void) record
  18.  -> valid record, newline                   =cleanUp();
  19.  -> bad data, newline                       =cleanUp();
  20.  
  21. bad data
  22.  -> error               =wrError(PCB.line, PCB.column);
  23.  
  24. (void) valid record
  25.  -> "class", attribute list                =putClass();
  26.  -> "instanceVariable",
  27.        attribute list           =putInstanceVariable();
  28. // six other record types handled similarly
  29.  
  30. attribute list
  31.  -> tab, attribute
  32.  -> attribute list, tab, attribute
  33.  
  34. (void) attribute
  35.  -> "name@", value:a                   =atAdd(NAME, a);
  36.  -> "file@", value:a                  =atAdd(FILEN, a);
  37.  -> "line@", value:a                   =atAdd(LINE, a);
  38. // twelve other attribute types handled similarly
  39.  
  40. (char *) value
  41.  -> value contents                          =release();
  42.  
  43. (void) value contents
  44.  -> value char:c                      =collectFirst(c);
  45.  -> value contents, value char:c           =collect(c);
  46.  
  47.  
  48. // =============== lexical definitions ================
  49. eof              = -1 + 0 + ^Z
  50. newline          = '\n'
  51. tab              = '\t'
  52. value char       = ~(eof + tab + '@' + newline)
  53.  
  54. // Supporting C++ code follows
  55. {
  56. int main(int argc, char * argv[]) {
  57.   if (FALSE == setErrorFile(argv[1])) {
  58.     fprintf(stderr, "Couldn't open error file\n");
  59.     return 1;
  60.   }
  61.   conv();
  62.   return 0;
  63. }
  64. }
  65.